﻿using GameEditor.View;
using GameEditor.View.Components;
using PureMVC.Interfaces;
using PureMVC.Patterns;
using GameEngine.View.Components;
using System;
using GameEngine.Model;
using GameEngine;

namespace GameEditor.Commands
{
    /// <summary>
    /// 
    /// </summary>
    public class CreateThingTypePropertiesEditor_Command<MyIdType> : SimpleCommand
        where MyIdType : IComparable<MyIdType>
    {
        override public void Execute(INotification notification)
        {
            //if (notification.Body == null)
            //throw new Exception("CreateEditorMainMenu_In_Command has to ");

            //var dataProxy = notification.Body as IThingTypeDataProxy<MyIdType>;

            var editorMediator = GameEditorViewFacade<MyIdType>.Instance.CreateThingTypeEditorMenuMediator(
                GameEditorFacade.ThingTypeEditorMediatorName,
                GameEditorViewFacade<MyIdType>.Instance.CreateThingTypeEditorMenuView()
                );
            
            foreach(var type in ModelFacade<MyIdType>.Instance.ThingTypeTypes.Keys)
                editorMediator.AddType(type);

            foreach (var view in ModelFacade<MyIdType>.Instance.Game.Views)
                editorMediator.AddView(view.Key);

            Facade.RegisterMediator(editorMediator);
        }
    }
}
